import time

import allure
from page_object.page_roncoo_add_user import PageLogin
from page_element.el_Roncoo import *
import logging



class EditLogin(PageLogin):
    """首页搜索商品后退出登录"""

    def page_search_user(self, info, case, expect):
        # 前置条件：已登录
        self.page_login('admin', '123456')
        with allure.step("点击用户管理"):
            self.click(home_pe.user_manage)
        with allure.step("点击用户信息"):
            self.click(home_pe.user_info)
        with allure.step(f"输入框输入搜索用户信息:{info}"):
            self.send_keys(home_pe.search_kuang, info)
        with allure.step("点击搜索按钮"):
            self.click(home_pe.search_btn)
        # 断言

        with allure.step("验证登录"):
            if '正例' in case:
                dy = self.text(home_pe.tiao_btn)
                logging.info(f"预期结果：{expect}，实际结果: {dy}")
                assert expect == dy, f"断言失败(验证失败): 期望包含'{expect}'，实际得到'{dy}'"
                logging.info(f"验证成功,{case}")
            else:
                dy = self.text(home_pe.tiao_btn)
                logging.info(f"预期结果：{expect}，实际结果: {dy}")
                assert expect == dy, f"断言失败(验证失败): 期望包含'{expect}'，实际得到'{dy}'"
                logging.info(f"验证成功,{case}")




